﻿using System.Collections.Generic;
using System.Web;
using System.Xml;

namespace SouthernLand.Common.UrlRewrite
{
    public class RuleController
    {
        private const string _configFilePath = "/Common/UrlRewrite/UrlRewrite.config";

        public static List<RuleInfo> GetRules()
        {
            var _lstRule = new List<RuleInfo>();
            var doc = new XmlDocument();
            doc.Load(HttpContext.Current.Server.MapPath(_configFilePath));
            XmlNodeList rules = doc.GetElementsByTagName("rule");
            foreach (XmlNode r in rules)
            {
                var rule = new RuleInfo();
                rule.Pattern = r.ChildNodes[0].InnerText;
                rule.SendTo = r.ChildNodes[1].InnerText;
                _lstRule.Add(rule);
            }
            return _lstRule;
        }
    }
}